<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>haohey经营报表</title>
	<meta name="decorator" content="default"/>
    <link href="${ctxStatic}/css/combo.select.css?v=1" rel="stylesheet">
    <script type="application/javascript" src="${ctxStatic}/js/jquery.min.js"></script>
    <script type="application/javascript" src="${ctxStatic}/js/jquery.combo.select.js?v=1"></script>
    <style>
        .combo-select{display: inline-block;}
    </style>
	<script type="text/javascript">
	$(document).ready(function() {
		$("#restaurantId").comboSelect();
		$(".form_datetime").datetimepicker({ 
			  language:'zh-CN',
			  todayBtn: false,
			  autoclose: true,
			  minView: "month",
			  format: 'yyyy-mm-dd'});
		/////$("#restaurantId").css('display','none'); 
		$("#restaurantLabel").css('display','none'); 
	});
    
	function findSummaryReport()
	{
		var postForm = document.getElementById("searchForm");
		if("" == postForm.beginTime.value || "" == postForm.endTime.value)
		{
			alert("时间为必填字段!");
			return false;
		}
		var startDate = postForm.beginTime.value;
		var endDate = postForm.endTime.value;
		
		var arys1= new Array();
		var arys2= new Array();
		arys1=startDate.split('-');
	    var sdate=new Date(arys1[0],parseInt(arys1[1]-1),arys1[2]);
	    
	    arys2=endDate.split('-');
	    var edate=new Date(arys2[0],parseInt(arys2[1]-1),arys2[2]);
		
	    if(sdate > edate) {
	        alert("日期开始时间大于结束时间");
	        return false;
	    }
		
		postForm.method="post" ;
		postForm.action = "${ctx}/report/report/haoheyReport" ;
		postForm.submit();
		return postForm;
	}
	
	function changeType()
	{
		var postForm = document.getElementById("searchForm");
		if("one" == postForm.reportType.value)
		{
			////$("#restaurantId").css('display','block');
			////inline-block 会显示，但是不会换行
			$("#restaurantLabel").css('display','inline-block'); 
		}else
		{
			/////$("#restaurantId").css('display','none'); 
			$("#restaurantLabel").css('display','none'); 
		}
	}
    
	</script>
</head>
<body>
	<ul class="nav nav-tabs nav-tabss">
		<li class="active"><a href="${ctx}/report/report/haoheyReport/">haohey经营报表</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="restaurantOrderDTO" action="${ctx}/report/report/" method="post" class="breadcrumb form-search form-inline">
            <label>报表类型：</label>
            <form:select path="reportType" htmlEscape="false" cssClass="form-control" onchange="changeType()">
            	<form:option value="" label="------请选择------"/>
	            <form:option value="all" label="整体报表"/>
	            <form:option value="one" label="餐厅分析报表"/>
            </form:select>
            
            <div id ="restaurantLabel" name ="restaurantLabel">
            <label>餐厅：</label>
            <form:select path="restaurantId" htmlEscape="false" cssClass="form-control">
               <form:option value="" label="餐厅名称"/>
               <form:options items="${restaurants}" itemLabel="name" itemValue="id"/> 
            </form:select>
            </div>
            
            <label>查询时间：</label>
            <div class="form-group" id="data_5">
            	<div class="input-daterange input-group" id="datepicker">
            		<input type="text" readonly class="input-sm form-control form_datetime" name="beginTime" id="beginTime" value="">
                	<span class="input-group-addon">到</span>
                	<input type="text" readonly class="input-sm form-control form_datetime" name="endTime" id="endTime" value="">
            	</div>
          	</div>
          	
		&nbsp;<input id="btnSubmit" class="btn btn-sm btn-primary" type="button" onclick = "findSummaryReport()" value="查询"/>
		
	</form:form>
	<tags:message content="${message}"/>


	<c:if test="${!empty restaurantList}">
		<p><b>商家注册数据报表</b></p>
	<table id="contentTable1" class="table table-striped table-bordered table-condensed">
		<thead><tr>
            <th>日期</th>
            <th>注册商家数量</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${restaurantList}" var="restaurantOrderDTO">
			<tr>
                <td>${restaurantOrderDTO.queryDate}</td>
                <td>${restaurantOrderDTO.numCount}</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	</c:if>
	

	<c:if test="${!empty staffList}">
	<p><b>员工新增数据报表</b></p>
		<table id="contentTable2" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
	            <th>日期</th>
            	<th>新增员工</th>
			</tr>
		</thead>
		<c:forEach items="${staffList}" var="restaurantOrderDTO">
			<tr>
				<td>${restaurantOrderDTO.queryDate}</td>
                <td>${restaurantOrderDTO.numCount}</td>
			</tr>
		</c:forEach>
		</table>
	</c:if>
	

	<c:if test="${!empty orderList}">
	<p><b>餐厅经营总数据</b></p>
	<table id="contentTable3" class="table table-striped table-bordered table-condensed">
		<thead><tr>
            <th>日期</th>
            <th>订单总数</th>
            <th>总金额</th>
            <th>实收总金额</th>
            <th>服务费总金额</th>
            <th>退费总金额</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${orderList}" var="restaurantOrderDTO">
			<tr>
                <td>${restaurantOrderDTO.queryDate}</td>
                <td>${restaurantOrderDTO.numCount}</td>
                <td>${restaurantOrderDTO.receivablePrice}</td>
                <td>${restaurantOrderDTO.actualReceivePrice}</td>
                <td>${restaurantOrderDTO.servicePrice}</td>
                <td>${restaurantOrderDTO.refundPrice}</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	</c:if>
	
	<c:if test="${!empty totalAmountList}">
	<p><b>餐厅经营报表</b></p>
		<table id="contentTable2" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
	            <th>日期</th>
            	<th>总收入</th>
            	<th>优惠总金额</th>
            	<th>服务费总金额</th>
            	<th>实收总金额</th>
            	<th>退款总金额</th>
			</tr>
		</thead>
		<c:forEach items="${totalAmountList}" var="restaurantOrderDTO">
			<tr>
				<td>${restaurantOrderDTO.queryDate}</td>
                <td>${restaurantOrderDTO.totalPrice}</td>
                <td>${restaurantOrderDTO.totalDiscountPrice}</td>
                <td>${restaurantOrderDTO.servicePrice}</td>
                <td>${restaurantOrderDTO.actualReceivePrice}</td>
                <td>${restaurantOrderDTO.refundPrice}</td>
                
			</tr>
		</c:forEach>
		</table>
	</c:if>
	
	<c:if test="${!empty categoryAmountList}">
	<p><b>餐厅套餐报表</b></p>
		<table id="contentTable2" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
	            <th>套餐ID</th>
            	<th>套餐名称</th>
            	<th>套餐英文名称</th>
            	<th>套餐中文名称</th>
            	<th>总收入</th>
            	<th>优惠总金额</th>
            	<th>订单总量</th>
			</tr>
		</thead>
		<c:forEach items="${categoryAmountList}" var="restaurantOrderDTO">
			<tr>
				<td>${restaurantOrderDTO.categoryId}</td>
                <td>${restaurantOrderDTO.name}</td>
                <td>${restaurantOrderDTO.englishName}</td>
                <td>${restaurantOrderDTO.chineseName}</td>
                <td>${restaurantOrderDTO.totalPrice}</td>
                <td>${restaurantOrderDTO.totalDiscountPrice}</td>
                <td>${restaurantOrderDTO.dishesNum}</td>
			</tr>
		</c:forEach>
		</table>
	</c:if>
	
	<c:if test="${!empty dishesAmountList}">
	<p><b>菜品经营报表</b></p>
		<table id="contentTable2" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
	            <th>菜品ID</th>
            	<th>套餐名称</th>
            	<th>套餐英文名称</th>
            	<th>套餐中文名称</th>
            	<th>总收入</th>
            	<th>优惠总金额</th>
            	<th>订单总量</th>
			</tr>
		</thead>
		<c:forEach items="${dishesAmountList}" var="restaurantOrderDTO">
			<tr>
				<td>${restaurantOrderDTO.dishesId}</td>
                <td>${restaurantOrderDTO.name}</td>
                <td>${restaurantOrderDTO.englishName}</td>
                <td>${restaurantOrderDTO.chineseName}</td>
                <td>${restaurantOrderDTO.totalPrice}</td>
                <td>${restaurantOrderDTO.totalDiscountPrice}</td>
                <td>${restaurantOrderDTO.dishesNum}</td>
			</tr>
		</c:forEach>
		</table>
	</c:if>
	
</body>
</html>
